package com.david4.jizhang.client;
public class Main {

	public static void main(String[] args) {
		String[] strArr1 = { "xiaoxin", "niutou", "shanqiu", "luobo" };
		String[] strArr2 = { "xiaoxin", "ggg", "shanqiu", "meile", "dddsf", "niutou" };
		int max = strArr1.length > strArr2.length ? strArr1.length : strArr2.length;
		int[] ary = new int[max*4];
		for (int i = 0; i < strArr1.length; i++) {
			int hash = hash(strArr1[i].hashCode());
			int index = indexFor(hash,max*4);
			ary[index] = 1;
		}
		for (int i = 0; i < strArr2.length; i++) {
			int hash = hash(strArr2[i].hashCode());
			int index = indexFor(hash,max*4);
			if(ary[index] == 1){
				System.out.println(strArr2[i]);
			}
		}
	}

    static int hash(int h) {
        h ^= (h >>> 20) ^ (h >>> 12);
        return h ^ (h >>> 7) ^ (h >>> 4);
    }

    static int indexFor(int h, int length) {
        return h & (length-1);
    }
}

